package service

import (
	"io/ioutil"
	"log"

	"time"

	"gopkg.in/yaml.v1"
)

type Config struct {
	Common struct {
		Version  string
		IsDebug  bool `yaml:"debug"`
		LogPath  string
		LogLevel string
	}

	Client struct {
		ServerAddr   string
		Apps         []string
		SyncInterval time.Duration
		AppStopWait  time.Duration
		AppStartWait time.Duration

		SupervisorInterval time.Duration
		Daemons            []string
		Timers             []string
		Sep                string
	}
}

var Conf = &Config{}

func init() {
	data, err := ioutil.ReadFile("taitan-client.yaml")
	if err != nil {
		log.Fatal("read config error :", err)
	}

	err = yaml.Unmarshal(data, &Conf)
	if err != nil {
		log.Fatal("yaml decode error :", err)
	}
}
